﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Deparment_Deparment_HomePage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    //新 闻
    public string WriteNews()
    {

        int i = 0;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        HZ.MBSM.DBUtility.Db db = new HZ.MBSM.DBUtility.Db();

        string strSql = "select top 6 Notid,Title,AddDate from Note order by Notid desc  ";
        System.Data.IDataReader dr = db.DataReader(strSql);

        sb.Append("<table  width='100%' border=0 align=center cellpadding=6 cellspacing=1>");
        while (dr.Read())
        {
            i++;
            sb.Append("<tr><td class='dotbottomline' >");
            sb.Append("<img src='../Images/Demparment/rtx.gif' width='8' height='8'>&nbsp;");
            if (dr["Title"].ToString().Trim().Length > 16)
            {
                sb.Append("<a href='ShowNote.aspx?Notid=" + SysFun.PasswordEncrypt(dr["Notid"].ToString()) + "' target=_blank  Title=" + dr["Title"].ToString() + ">" + dr["Title"].ToString().Remove(12) + "...</a>");
            }
            else
            {
                sb.Append("<a href='ShowNote.aspx?Notid=" + SysFun.PasswordEncrypt(dr["Notid"].ToString()) + "' target=_blank  Title=" + dr["Title"].ToString() + ">" + dr["Title"].ToString().Trim() + "</a>");
            }
            if (System.DateTime.Now <= Convert.ToDateTime(dr["AddDate"]).AddDays(4))
                sb.Append("<img src='../images/new.gif' width='28' height=11>");
            sb.Append("</td><td align='right' class='dotbottomline'>[" + Convert.ToDateTime(dr["AddDate"]).ToShortDateString() + "]</td></tr>");
        }
        for (int j = i; j < 5; j++)
            sb.Append("<tr><td class='dotbottomline'>&nbsp;</td><td  class='dotbottomline' ></td></tr>");

  
        sb.Append("</table>");
        dr.Close();
        dr.Dispose();
        db.Close();

        return sb.ToString();
       
    }

    //部门内部信息
    public string WriteNote()
    {
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        int i = 0;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        HZ.MBSM.DBUtility.Db db = new HZ.MBSM.DBUtility.Db();

        string strSql = "select top 6 * from WithinInfo where (accountid =" + _Account.AccountId + " or accountid=6621) and info_sort=1  order by WithinInfoId desc ";
        System.Data.IDataReader dr = db.DataReader(strSql);

        sb.Append("<table  width='100%' border=0 align=center cellpadding=6 cellspacing=1>");
        while (dr.Read())
        {
            i++;
            sb.Append("<tr><td class='dotbottomline' >");
            sb.Append("<img src='../Images/Demparment/rtx.gif' width='8' height='8'>&nbsp;");
            if (dr["Title"].ToString().Trim().Length > 16)
            {
                sb.Append("<a href='ShowNote.aspx?WithinInfoId=" + SysFun.PasswordEncrypt(dr["WithinInfoId"].ToString()) + "' target=_blank  Title=" + dr["Title"].ToString() + ">" + dr["Title"].ToString().Remove(12) + "...</a>");

            }
            else
            {
                sb.Append("<a href='ShowNote.aspx?WithinInfoId=" + SysFun.PasswordEncrypt(dr["WithinInfoId"].ToString()) + "' target=_blank  Title=" + dr["Title"].ToString() + ">" + dr["Title"].ToString().Trim() + "</a>");
            }
            if (System.DateTime.Now <= Convert.ToDateTime(dr["AddDate"]).AddDays(4))
                sb.Append("&nbsp;<img src='../images/new.gif' width='28' height=11>");
            sb.Append("</td><td align='right' class='dotbottomline'>[" + Convert.ToDateTime(dr["AddDate"]).ToShortDateString() + "]</td></tr>");
        }
        for (int j = i; j < 6; j++)
            sb.Append("<tr><td class='dotbottomline'>&nbsp;</td><td  class='dotbottomline' ></td></tr>");


        sb.Append("</table>");
        dr.Close();
        dr.Dispose();
        db.Close();

        return sb.ToString();

    }

    //政策法规
    public string Writelower()
    {
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        int i = 0;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        HZ.MBSM.DBUtility.Db db = new HZ.MBSM.DBUtility.Db();

        string strSql = "select top 6 * from D_duty_lower where accountid =" + _Account.AccountId + " and info_sort=2  order by duty_lowerid desc ";
        System.Data.IDataReader dr = db.DataReader(strSql);

        sb.Append("<table  width='100%' border=0 align=center cellpadding=6 cellspacing=1>");
        while (dr.Read())
        {
            i++;
            sb.Append("<tr><td class='dotbottomline' >");
            sb.Append("<img src='../Images/Demparment/rtx.gif' width='8' height='8'>&nbsp;");
            if (dr["Title"].ToString().Trim().Length > 16)
            {
                sb.Append("<a href='ShowNote.aspx?duty_lowerid=" + SysFun.PasswordEncrypt(dr["duty_lowerid"].ToString()) + "' target=_blank  Title=" + dr["Title"].ToString() + ">" + dr["Title"].ToString().Remove(12) + "...</a>");
          
            }
            else
            {
                sb.Append("<a href='ShowNote.aspx?duty_lowerid=" + SysFun.PasswordEncrypt(dr["duty_lowerid"].ToString()) + "' target=_blank  Title=" + dr["Title"].ToString() + ">" + dr["Title"].ToString().Trim() + "</a>");
            }
            if (System.DateTime.Now <= Convert.ToDateTime("2008-1-1").AddDays(4))
                sb.Append("<img src='../images/new.gif' width='28' height=11>");
            sb.Append("</td><td align='right' class='dotbottomline'>[" + Convert.ToDateTime("2008-1-1").ToShortDateString() + "]</td></tr>");
        }
        for (int j = i; j < 6; j++)
            sb.Append("<tr><td class='dotbottomline'>&nbsp;</td><td  class='dotbottomline' ></td></tr>");


        sb.Append("</table>");
        dr.Close();
        dr.Dispose();
        db.Close();

        return sb.ToString();

    }
    //文档下载
    public string Writedd()
    {
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        int i = 0;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        HZ.MBSM.DBUtility.Db db = new HZ.MBSM.DBUtility.Db();

        string strSql = "select top 6 * from D_duty_lower where accountid =" + _Account.AccountId + " and info_sort=2  order by duty_lowerid desc ";
        System.Data.IDataReader dr = db.DataReader(strSql);

        sb.Append("<table  width='100%' border=0 align=center cellpadding=6 cellspacing=1>");
        while (dr.Read())
        {
            i++;
            sb.Append("<tr><td class='dotbottomline' >");
            sb.Append("<img src='../Images/Demparment/rtx.gif' width='8' height='8'>&nbsp;");
            if (dr["Title"].ToString().Trim().Length > 16)
            {
             //   sb.Append("<a href='ShowNote.aspx?duty_lowerid=" + SysFun.PasswordEncrypt(dr["duty_lowerid"].ToString()) + "' target=_blank  Title=" + dr["Title"].ToString() + ">" + dr["Title"].ToString().Remove(12) + "...</a>");

            }
            else
            {
               // sb.Append("<a href='ShowNote.aspx?duty_lowerid=" + SysFun.PasswordEncrypt(dr["duty_lowerid"].ToString()) + "' target=_blank  Title=" + dr["Title"].ToString() + ">" + dr["Title"].ToString().Trim() + "</a>");
            }
            if (System.DateTime.Now <= Convert.ToDateTime("2008-1-1").AddDays(4))
                sb.Append("<img src='../images/new.gif' width='28' height=11>");
            sb.Append("</td><td align='right' class='dotbottomline'>[" + Convert.ToDateTime("2008-1-1").ToShortDateString() + "]</td></tr>");
        }
        for (int j = i; j < 6; j++)
            sb.Append("<tr><td class='dotbottomline'>&nbsp;</td><td  class='dotbottomline' ></td></tr>");


        sb.Append("</table>");
        dr.Close();
        dr.Dispose();
        db.Close();

        return sb.ToString();

    }
}
